using System;
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
using Twitterizer;
using data.contracts;

namespace twittersearch.tests
{
    [TestFixture]
    public class MapperTests
    {
        private Mapper sut;
        private IEnumerable<Tweet> result;

        [SetUp]
        public void Setup() {
            sut = new Mapper();
            result = null;
            sut.Out_Result += x => result = x;
        }

        [Test]
        public void Tweets_werden_gemappt() {
            var twitterSearchResultCollection = new TwitterSearchResultCollection {
                new TwitterSearchResult {
                    FromUserScreenName = "Paul",
                    ProfileImageLocation = "pic#1",
                    CreatedDate = new DateTime(2003, 2, 1, 12, 05, 00),
                    Source = "<a href='http://twitter.com'>web</a>",
                    Text = "Hello world"
                }
            };
            sut.In_Map(twitterSearchResultCollection);

            Assert.That(result.Count(), Is.EqualTo(1));
            var tweet = result.First();
            Assert.That(tweet.Name, Is.EqualTo("@Paul, 01.Feb 12:05 via web"));
            Assert.That(tweet.ImageSource, Is.EqualTo("pic#1"));
            Assert.That(tweet.Text, Is.EqualTo("Hello world"));
        }
    }
}